package com.sgj.observer;

import lombok.extern.slf4j.Slf4j;

/**
 * 摄氏度组件
 * @Author: Guoji Shen
 * @Date: 2022/11/7 14:04
 */
@Slf4j
public class CelsiusView implements MyObserver{

    @Override
    public void update(Subject subject) {
        // 确定目标对象为 Weather 类，才获取新状态
        if (subject instanceof Weather) {
            Weather weather = (Weather) subject;
            float temperature = weather.getTemperature();
            log.info("摄氏温度 View:{}", temperature);
        }
    }
}